package com.xd.sys.controller;

import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;

/**
 * 工作台的控制器
 */
@Controller
@RequestMapping("desk")
public class DeskManager {

    /**
     * 跳转到工作台的页面
     */
    @RequestMapping("toDeskManager")
    public String toDeskManager(HttpServletRequest req) throws FileNotFoundException {

        System.err.println("路径：");
        String servletPath = req.getServletPath();
        System.out.println("servletPath:"+servletPath);
        System.err.println("路径2：");
        String path = ResourceUtils.getURL("classpath:").getPath()+"uploadxd";
        System.out.println("path:"+path);
        /**
         * path:/D:/xd的博客/他人资料/尚硅谷-雷哥项目/汽车出租管理系统
         * /warehouse_management_system_1/rent-mannager
         * /target/carRental/WEB-INF/classes/uploadxd
         */

        String xd = req.getSession().getServletContext().getRealPath("/xd");


        String resource = this.getClass().getClassLoader().getResource("").toString();
        File file=new File(resource,"xd");
        file.mkdirs();


        //获取项目名 /rent   部署时的名字
        String contextPath = req.getContextPath();
        System.out.println("项目名："+contextPath);
        System.out.println("path::::::::"+resource);
        return "system/main/deskManager";
    }

}
